#include "libs/waitqueue.h"


Waitqueue::Waitqueue(/* args */)
{
    count = 0;
}

Waitqueue::~Waitqueue()
{

}

void Waitqueue::wakeUp()
{

    
    if(waitQueue.isEmpty())
        return;
    
    
    task* tsk = waitQueue.pop();
    count--;
    TASKMANAGER->wakeupProcess(tsk);
    
}

void Waitqueue::sleepOn()
{
    
    waitQueue.push(current);
    count++;
    uint64_t cpuid = getAPICID();
    current->state = TASK_UNINTERRUPTIBLE;
    TASKMANAGER->shcedule();

}

void Waitqueue::interruptibleSleepOn()
{
    waitQueue.push(current);
    uint64_t cpuid = getAPICID();
    current->state = TASK_INTERRUPTIBLE;
    TASKMANAGER->shcedule();

}

